package test.my.com.myapplicationtest.tool_bar;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;

import butterknife.Bind;
import butterknife.ButterKnife;
import test.my.com.myapplicationtest.R;
import test.my.com.myapplicationtest.utils.ToastUtil;

/**
 * Author : Cooper
 * Time : 2016/9/18  11:22
 * Description :
 */
public class ToolBarActivity extends AppCompatActivity {

    @Bind(R.id.toolbar)
    Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.aty_tool_bar_layout);
        ButterKnife.bind(this);

        toolbar.setTitle("仅供测试");
        setSupportActionBar(toolbar);

//        toolbar.inflateMenu(R.menu.tool_bar_menu);
//        toolbar.setLogo(R.drawable.ic_account_leo);
        toolbar.setNavigationIcon(R.drawable.ic_navbar_back_h);
        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.search_item:
                        ToastUtil.showToast("search_item  == "+item.getTitle().toString());
                        break;
                    case R.id.set_item:
                        ToastUtil.showToast("set_item  == "+item.getTitle().toString());
                        break;
                    case R.id.news_item:
                        ToastUtil.showToast("news_item  == "+item.getTitle().toString());
                        break;
                    case R.id.about_item:
                        ToastUtil.showToast("about_item  == "+item.getTitle().toString());
                        break;
                }
                return false;
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.tool_bar_menu,menu);
        return super.onCreateOptionsMenu(menu);
    }
}
